<template>
  <div class="device-stats">
    <h2>设备统计</h2>
    <div class="online-rate">
      <span>在线率</span>
      <span>{{ onlineRate }}%</span>
    </div>
    <div class="stats">
      <div class="stat-item" v-for="(item, index) in statsData" :key="index">
        <i :class="['fa', item.icon]"></i>
        <span>{{ item.label }}</span>
        <span>{{ item.value }}</span>
      </div>
    </div>
    <div class="legend">
      <span><i class="fa fa-circle" style="color: #00bfff;"></i> 在线</span>
      <span><i class="fa fa-circle" style="color: #007bff;"></i> 离线</span>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      onlineRate: 100.00,
      statsData: [
        { label: '设备总数', value: 2, icon: 'fa-laptop' },
        { label: '在线设备', value: 2, icon: 'fa-laptop' },
        { label: '离线设备', value: 0, icon: 'fa-laptop' },
        { label: '变量报警', value: 0, icon: 'fa-exclamation-triangle' }
      ]
    };
  }
};
</script>

<style scoped>
.device-stats {
  background-color: #0a0e17;
  color: white;
  padding: 20px;
  border-radius: 10px;
}
.online-rate {
  font-size: 24px;
  margin-bottom: 20px;
}
.stats .stat-item {
  display: inline-block;
  width: 25%;
  text-align: center;
  margin-bottom: 20px;
}
.legend span {
  margin-right: 10px;
}
</style>